package com.suitsoft.ut.dao.base;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.hibernate.HibernateDao;

import com.suitsoft.ut.entity.base.Team;
import com.suitsoft.ut.util.StringUtils;

/**
 *
 *@author Suineg
 */
@Repository
public class TeamDao extends HibernateDao<Team,Long>{
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	public Page<Team> findAllByCollege(Page<Team> page,String colldeCode){
		String hql = "from Team as tt ";
		if(!StringUtils.isEmpty(colldeCode)){
			hql += " where tt.college.id in (" +colldeCode + ")";
		}
		if(page.isOrderBySetted()){
			hql += " order by " + page.getOrderBy() + " " + page.getOrder();
		}
		return findPage(page,hql);
	}
	
	public List<Team> findAllByCollege(String colldeCode){
		String hql = "from Team as tt ";
		if(!StringUtils.isEmpty(colldeCode)){
			hql += " where tt.college.id in (" +colldeCode + ")";
		}
		return find(hql);
	}

}

